<!DOCTYPE html>
<html class="no-js" lang="zh_CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

    <title>${system_admin_title}</title>
    #required_css
</head>

<body>
<div class="app \$!layout">
    <!-- 头部菜单 -->
    <section class="layout">
        <!-- 菜单 -->
        <section class="container">
            <!-- 内容主体 -->
            <section class="main-content">
                <!-- 主体操作栏 -->
                <header class="header navbar">
                    <!-- 左按钮区 -->
                    <div class="btn-group tool-button">
                        <a class="btn btn-primary navbar-btn" onclick="doAddBiReport()"><i class="fa fa-plus"></i> 新增报表</a>
                    </div>
                    <div class="pull-right offscreen-right">
                    </div>
                </header>
                <div class="content-wrap">
                    <div class="wrapper">
                        <div class="row">
                            <div class="col-lg-12 col-md-12">
                                <table id="dgBiReport"></table>
                                <div id="dgBiReportPager"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <a class="exit-offscreen"></a>
            </section>
        </section>
    </section>
</div>
#required_js
<script type="text/javascript">
    ns.requireJS("/framework/js/view/datagrid.js");
    var dgBiReport;
    ns.ready(function () {
        dgBiReport = $("#dgBiReport").jqGrid({
            url: '$!basePath/bi/report/data',
            colModel: [
                {label: "ID", name: "id", key: true, hidden: true},
                {label: "报表名称", name: "name"},
                {label: "描述", name: "descript"},
                {label: "创建人", name: "createUser"},
                {label: "创建时间", name: "createTime"},
                {
                    label: '操作', formatter: function (val, node, data) {
                    return ns.view.datagrid.renderOp([
                        {
                            title: "查看详情", onclick: function () {
                            ns.view.showModal("$!basePath/bi/report/detail/" + data.id);
                        }
                        },
                        {
                            title: "编辑", onclick: function () {
                            ns.view.showModal("$!basePath/bi/report/edit/" + data.id, {
                                onHidden: function (dialog, obj) {
                                    if (dialog.isEdited) {
                                        dgBiReport.reload();
                                    }
                                }
                            });
                        }
                        },
                        {
                            title: "删除", onclick: function () {
                            doDeleteBiReport(data.id);
                        }
                        },
                        {divider : true},
                        {
                            title : "设计报表",
                            url : "$!basePath/bi/report/design/"+data.id,
                            target : "_blank"
                        },
                        {
                            title : "浏览报表",
                            url : "$!basePath/bi/report/view/"+data.id,
                            target : "_blank"
                        }
                    ]);
                }
                }
            ],
            rownumbers: true,
            height: $(".wrapper").height() - ns.view.datagrid.offsetHeight,
            pager: "#dgBiReportPager"
        });
    });
    function doAddBiReport() {
        ns.view.showModal("$!basePath/bi/report/add", {
            onHidden: function (dialog, obj) {
                if (dialog.isSaved) {
                    dgBiReport.reload();
                }
            }
        });
    }
    function doDeleteBiReport(id) {
        ns.tip.confirm("确定要删除此条数据吗？", function () {
            ns.get("$!basePath/bi/report/delete/" + id, function (success, data) {
                if (success) {
                    ns.tip.toast.success("数据已删除");
                    dgBiReport.reload();
                } else {
                    ns.tip.toast.error(data.message);
                }
            });
        });
    }
</script>
</body>
</html>